<template>
    <div>
        <h1>计数器{{ proxy }}</h1>
        <button @click="handler">点击我+1</button>
    </div>
</template>

<script lang="ts">
//readctive:一般用于定义引用类型的数据---->响应式
import { defineComponent, reactive } from 'vue'
export default defineComponent({
    setup() {
        const target = { a: 1, b: 2 };
        const proxy:any = reactive(target);
        return {
            proxy,
            handler() {
                proxy.a++;
            }
        }
    }
})
</script>

<style scoped></style>